{extend name="layout/layout" /}

{block name="title"}管理{/block}

登录页

{block name="content"}
{if condition="$Think.session.user.rights eq 1"}
<a href="{:url('user/index')}">组长管理</a>
{/if}

<a class="logio" href="{:url('index/logout')}">注销</a>
<h3>微信号管理</h3>

{if condition="$Think.session.user.rights eq 1"}
{volist name="groups" id="group"}
分组：{$group.name}{$group.selected? ',已启用' : ''}
<a href="{:url('group/delete/')}{$group.id}"> 删除</a>
<table border="1">
    <tr>
        <th>微信名</th>
        <th>微信号</th>
        <th>二维码</th>
        <th>吸粉数</th>
        <th>状态</th>
        <th>备注</th>
        <th>操作</th>
    </tr>
    {volist name="accounts" id="account"}
        {if condition="$account.group_id eq $group.id"}
        <tr>
            <td>{$account.name}</td>
            <td>{$account.wechat_id}</td>
            <td><img class="admin-code" src="/{$account.qr_img}"></td>
            <td>
                <form action="{:url('account/fans')}">
                    <input type="text" name="fans" value="{$account.fans}">
                    <input type="hidden" name="id" value="{$account.id}">
                    <input type="submit" value="修改">
                </form>
            </td>
            <td>
                {switch name="$account.status" }
                    {case value="1"}吸粉{/case}
                    {case value="2"}暂停{/case}
                    {case value="3"}封号{/case}
                {/switch}
            </td>
            <td>{$account.remarks}</td>
            <td>
                <a href="{:url('account/edit',array('id'=>$account.id))}">编辑</a>，
                <a href="{:url('account/delete',array('id'=>$account.id))}">删除</a>
            </td>
        </tr>
        {/if}
    {/volist}
</table><br>
{/volist}

{else /}
{volist name="groups" id="group"}
{if condition="$Think.session.user.group_id eq $group.id"}
分组：{$group.name}{$group.selected? ',已启用' : ''}
<table border="1">
    <tr>
        <th>微信名</th>
        <th>微信号</th>
        <th>二维码</th>
        <th>吸粉数</th>
        <th>状态</th>
        <th>备注</th>
        <th>操作</th>
    </tr>
    {volist name="accounts" id="account"}
        {if condition="$account.group_id eq $group.id"}
        <tr>
            <td>{$account.name}</td>
            <td>{$account.wechat_id}</td>
            <td><img class="admin-code" src="/{$account.qr_img}"></td>
            <td>
                <form action="{:url('account/fans')}">
                    <input type="text" name="fans" value="{$account.fans}">
                    <input type="hidden" name="id" value="{$account.id}">
                    <input type="submit" value="修改">
                </form>
            </td>
            <td>
                {switch name="$account.status" }
                    {case value="1"}吸粉{/case}
                    {case value="2"}暂停{/case}
                    {case value="3"}封号{/case}
                {/switch}
            </td>
            <td>{$account.remarks}</td>
            <td>
                <a href="{:url('account/edit',array('id'=>$account.id))}">编辑</a>，
                <a href="{:url('account/delete',array('id'=>$account.id))}">删除</a>
            </td>
        </tr>
        {/if}
    {/volist}
</table><br>
{/if}
{/volist}

{/if}
<hr>

{if condition="$Think.session.user.rights eq 1"}
<h4>启用分组</h4>
<form action="{:url('group/selected')}" method="POST">
    {volist name="groups" id="group"}
    <input type="checkbox" name="ids[]" value="{$group.id}" {$group.selected?'checked':''}> {$group.name}
    {/volist}
    <br><input type="submit" value="确定">
</form>
<hr>

<h4>新增分组</h4>
<form action="{:url('group/save')}" method="POST">
    分组名：<input type="text" name="name"><br>
    备注： <input type="text" name="remarks"><br>
    <input type="submit" value="确定">
</form>
<hr>
{/if}

<h4>新增微信号</h4>
<form action="{:url('account/save')}" method="POST" enctype="multipart/form-data">
    {if condition="$Think.session.user.rights eq 1"}
        所属分组：
        <select name="group_id">
            {volist name="groups" id="group"}
            <option value="{$group.id}">{$group.name}</option>
            {/volist}
        </select>
        <br>
    {else /}
        <input type="hidden" name="group_id" value="{$Think.session.user.group_id}">
    {/if}
    名称 ：<input type="text" name="name"><br>
    微信号：<input type="text" name="wechat_id"><br>
    原始粉丝：<input type="text" name="fans" value="0"><br>
    备注： <input type="text" name="remarks"><br>
    上传二维码：<input type="file" name="qrcode"><br>
    <input type="submit" value="确定">
</form>
<hr>

{if condition="$Think.session.user.rights eq 1"}
<h4>新增组长</h4>
<form action="{:url('user/save')}" method="POST">
    所属分组：
    <select name="group_id">
        {volist name="groups" id="group"}
        <option value="{$group.id}">{$group.name}</option>
        {/volist}
    </select>
    <br>
    组长名：<input type="text" name="username"><br>
    密码：<input type="text" name="password"><br>
    <input type="submit" value="确定">
</form>
<hr>

{/if}
{/block}
